cmake_minimum_required(VERSION 3.31)
project(sqlite3_study C)

set(CMAKE_C_STANDARD 11)

include_directories(./sqlite/tsrc)
include_directories(./sqlite/ext/rtree)

aux_source_directory(./sqlite/tsrc SOURCE)
list(REMOVE_ITEM SOURCE ./sqlite/tsrc/geopoly.c)
list(REMOVE_ITEM SOURCE ./sqlite/tsrc/tclsqlite.c)

add_compile_definitions(SQLITE_CORE)

add_compile_definitions(SQLITE_ENABLE_FTS4)
add_compile_definitions(SQLITE_ENABLE_FTS5)
add_compile_definitions(SQLITE_ENABLE_ICU)
add_compile_definitions(SQLITE_ENABLE_GEOPOLY)
add_compile_definitions(SQLITE_ENABLE_MATH_FUNCTIONS)
add_compile_definitions(SQLITE_ENABLE_PREUPDATE_HOOK)
add_compile_definitions(SQLITE_ENABLE_RTREE)
add_compile_definitions(SQLITE_ENABLE_SESSION)
add_compile_definitions(SQLITE_THREADSAFE)
add_compile_definitions(SQLITE_ENABLE_DBSTAT_VTAB)
add_compile_definitions(SQLITE_ENABLE_BYTECODE_VTAB)
add_compile_definitions(SQLITE_ENABLE_OFFSET_SQL_FUNC)
add_compile_definitions(SQLITE_STRICT_SUBTYPE)
add_compile_definitions(SQLITE_ENABLE_DBPAGE_VTAB)
add_compile_definitions(SQLITE_ENABLE_STMTVTAB)
#add_compile_definitions(NDEBUG)
add_compile_definitions(SQLITE_DEBUG)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    link_libraries(m)
    link_libraries(pthread)
    link_libraries(dl)
    link_libraries(icuuc)
    link_libraries(icudata)
    link_libraries(icui18n)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
    include_directories(icu4c-77_1-Win64-MSVC2022/include)
    link_directories(icu4c-77_1-Win64-MSVC2022/lib64)
    link_libraries(icuuc.lib)
    link_libraries(icudt.lib)
    link_libraries(icuin.lib)
    file(COPY icu4c-77_1-Win64-MSVC2022/bin64/icudt77.dll DESTINATION ${CMAKE_BINARY_DIR})
    file(COPY icu4c-77_1-Win64-MSVC2022/bin64/icuuc77.dll DESTINATION ${CMAKE_BINARY_DIR})
    file(COPY icu4c-77_1-Win64-MSVC2022/bin64/icuin77.dll DESTINATION ${CMAKE_BINARY_DIR})
endif ()
# 创建目标
add_executable(sqlite3_study ${SOURCE})

